package com.booking.common.exception;

import com.booking.common.enums.BookingErrorCode;
import lombok.Data;

/**
 * @author Qikai.Lin
 * @date 2023/4/21
 */
@Data
public class BookingException extends RuntimeException{
    private final String code;
    private final String msg;

    public BookingException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BookingException(BookingErrorCode errorCode) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }

    public BookingException(String code, Throwable throwable) {
        super(throwable);
        this.code = code;
        this.msg = throwable.getLocalizedMessage();
    }
}
